//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "Graphics/GLES/opengles.h"

namespace Engine
{
namespace Graphics
{
	
	struct gl_vertex
	{
		enum type
		{
			INT8			= gles::GL_BYTE,
			UINT8			= gles::GL_UNSIGNED_BYTE,
			INT16			= gles::GL_SHORT,
			UINT16			= gles::GL_UNSIGNED_SHORT,
			HALF			= gles::OES_vertex_half_float::GL_HALF_FLOAT,
			FLOAT			= gles::GL_FLOAT,
			FIXED			= gles::GL_FIXED,
			INT_10_10_10_2	= gles::OES_vertex_type_10_10_10_2::GL_INT_10_10_10_2,
			UINT_10_10_10_2	= gles::OES_vertex_type_10_10_10_2::GL_UNSIGNED_INT_10_10_10_2,
		};
	};



	//
	// Vertex Info
	//

	template <typename T>
	struct VertexInfo
	{
	};


	template <>
	struct VertexInfo <float>
	{
		typedef float	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::FLOAT; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return false; }
	};


	template <>
	struct VertexInfo <fixed_t>
	{
		typedef fixed_t	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::FIXED; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return false; }
	};


	template <>
	struct VertexInfo <half>
	{
		typedef half	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::HALF; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return false; }
	};


	template <>
	struct VertexInfo <int16>
	{
		typedef int16	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::INT16; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return true; }
	};


	template <>
	struct VertexInfo <uint16>
	{
		typedef uint16	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::UINT16; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return true; }
	};


	template <>
	struct VertexInfo <int8>
	{
		typedef int8	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::INT8; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return true; }
	};


	template <>
	struct VertexInfo <uint8>
	{
		typedef uint8	type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::UINT8; }
		static uint				Count ()		{ return 1; }
		static bool				Normalized ()	{ return true; }
	};


	template <typename T, uint8 I>
	struct VertexInfo < TVec<T,I> >
	{
		typedef TVec<T,I>					type_t;
		typedef typename type_t::value_t	value_t;

		static gl_vertex::type	Type ()			{ return VertexInfo< value_t >::Type(); }
		static uint				Count ()		{ return type_t::Count(); }
		static bool				Normalized ()	{ return VertexInfo< value_t >::Normalized(); }
	};


	template <>
	struct VertexInfo <color4u>
	{
		typedef color4u		type_t;

		static gl_vertex::type	Type ()			{ return gl_vertex::UINT8; }
		static uint				Count ()		{ return color4u::Count(); }
		static bool				Normalized ()	{ return true; }
	};


}	// Graphics
}	// Engine
